//package com.dalin.framework.common.eg.analyzexml;
//
//import java.io.File;
//import java.io.StringWriter;
//import java.util.Iterator;
//import java.util.List;
//
//import org.dom4j.Document;
//import org.dom4j.DocumentHelper;
//import org.dom4j.Element;
//import org.dom4j.io.SAXReader;
//import org.dom4j.io.XMLWriter;
//
//public class Dom4jTest {
//	public static void main(String[] args) {
////		readXml(new File(
////				"E:/workspace/cutedalin/src/com/dalin/common/eg/analyzexml/data.xml"));
////		String xmlString = "<html>" + "<head>" + "<title>dom4j解析一个例子</title>"
////				+ "<script>" + "<username>yangrong</username>"
////				+ "<password>123456</password>" + "</script>" + "</head>"
////				+ "<body>" + "<result>0</result>" + "<form>"
////				+ "<banlce>1000</banlce>" + "<subID>36242519880716</subID>"
////				+ "</form>" + "</body>" + "</html>";
////		readXml(xmlString);
//		try {
//			System.out.println(getXmlStr(new File("E:/workspace/egAxis1.4/src/com/adc/user/data.xml")));
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
//
//	public static void readXml(String xmlStr) {
//		 Document doc = null;
//		 try {
//			 doc = DocumentHelper.parseText(xmlStr); // 将字符串转为XML
//			 Element rootElt = doc.getRootElement(); // 获取根节点
//			 System.out.println("根节点：" + rootElt.getName()); // 拿到根节点的名称
//			 Iterator iter = rootElt.elementIterator("head"); // 获取根节点下的子节点head
//			 // 遍历head节点
//			 while (iter.hasNext()) {
//				 Element recordEle = (Element) iter.next();
//				 String title = recordEle.elementTextTrim("title"); // 拿到head节点下的子节点title值
//				 System.out.println("title:" + title);
//				 Iterator iters = recordEle.elementIterator("script"); // 获取子节点head下的子节点script
//				 // 遍历Header节点下的Response节点
//				 while (iters.hasNext()) {
//					 Element itemEle = (Element) iters.next();
//					 String username = itemEle.elementTextTrim("username"); // 拿到head下的子节点script下的字节点username的值
//					 String password = itemEle.elementTextTrim("password");
//					 System.out.println("username:" + username);
//					 System.out.println("password:" + password);
//				 }
//			 }
//		 } catch (Exception e) {
//			 e.printStackTrace();
//		 }
//	}
//
//	public static void readXml(File f) {
//		SAXReader saxReader = null;
//		Document doc = null;
//		try {
//			saxReader = new SAXReader();
//			doc = saxReader.read(f);
//			List<Element> list = doc
//					.selectNodes("/root/Cdc/CdcEntry/Items/CdcEntryItem");
//			for (Element CdcEntryItem : list) {
//				String key = CdcEntryItem.elementTextTrim("Key");
//				if ("BankMessage".equals(key)) {
//					System.out.println(CdcEntryItem.elementTextTrim("Value"));
//					return;
//				}
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//
//	}
//
//	public static String getXmlStr(File f) throws Exception {
//		SAXReader saxReader = new SAXReader();
//		Document doc = saxReader.read(f);
//		StringWriter   sw   =   new   StringWriter();
//	      XMLWriter   xw   =   new   XMLWriter(sw);
//	      xw.write(doc);
//	      xw.close();
//		return  sw.toString();
//	}
//
//}
